package com.drg.center.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.drg.center.entity.SysDoctorPO;
import com.drg.center.mapper.SysDoctorMapper;
import com.guaike.core.mybatis.plugins.BaseDAO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class SysDoctorDAO extends BaseDAO<SysDoctorMapper, SysDoctorPO> {

    public List<SysDoctorPO> findList(String keyword){
        LambdaQueryWrapper<SysDoctorPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        if(StringUtils.isNotBlank(keyword)){
            lambdaQueryWrapper.eq(SysDoctorPO::getDoctorCode, keyword).or( qw -> qw.like(SysDoctorPO::getDoctorName, keyword));
        }
        lambdaQueryWrapper.last("limit 0,20");
        lambdaQueryWrapper.orderByAsc(SysDoctorPO::getDepartCode);
        return getBaseMapper().selectList(lambdaQueryWrapper);
    }
}
